package com.example.design.行为型设计模式.策略模式;

public class StrategyMain {
    public static void main(String[] args) {
        ShoppingCart cart = new ShoppingCart();

        // 添加商品到购物车
        cart.addItem("Laptop");
        cart.addItem("Headphones");

        // 使用信用卡支付
        cart.setPaymentStrategy(new CreditCardPayment("1234-5678-9012-3456"));
        cart.checkout(1500);

        // 使用PayPal支付
        cart.setPaymentStrategy(new PayPalPayment("user@example.com"));
        cart.checkout(1500);

        // 使用银行转账支付
        cart.setPaymentStrategy(new BankTransferPayment("987654321"));
        cart.checkout(1500);
    }
}
